package com.zzzy.framework.aspect;

import com.zzzy.framework.common.annotation.DataPermission;
import com.zzzy.framework.common.util.DataPermissionHolder;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

/**
 * Description: 数据权限标识切面
 *
 * @author fc
 * @date 2024/5/20
 */
@Aspect
@Component
public class DataPermissionAspect {

    @Before("@annotation(dataPermission)")
    public void before(JoinPoint joinPoint, DataPermission dataPermission) {
        DataPermissionHolder.setIsFilterData(true);
    }

    @After("@annotation(dataPermission)")
    public void afterAdvice(JoinPoint joinPoint, DataPermission dataPermission) {
        DataPermissionHolder.clearContext();
    }
}
